package com.ws.client;

import org.apache.cxf.endpoint.Client;
import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;
import org.apache.cxf.transport.http.HTTPConduit;
import org.apache.cxf.transports.http.configuration.HTTPClientPolicy;

/**
 * @ClassName demo
 * @Description TODO
 * @Author zhengchenggong
 * @Date 2020/7/14 3:08 下午
 * @Version 1.0
 **/
public class ClientDemo {
    public static void main(String[] args) {
        //创建动态客户端
        JaxWsDynamicClientFactory factory = JaxWsDynamicClientFactory.newInstance();
        Client client = factory.createClient("http://localhost:8888/apis/api?wsdl");
        // 需要密码的情况需要加上用户名和密码
        //client.getOutInterceptors().add(new ClientLoginInterceptor(USER_NAME,PASS_WORD));
        HTTPConduit conduit = (HTTPConduit) client.getConduit();
        HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
        httpClientPolicy.setConnectionTimeout(2000);  //连接超时
        httpClientPolicy.setAllowChunking(false);    //取消块编码
        httpClientPolicy.setReceiveTimeout(120000);     //响应超时
        conduit.setClient(httpClientPolicy);
        //client.getOutInterceptors().addAll(interceptors);//设置拦截器
        try {
            Object[] objects = new Object[0];
            // invoke("方法名",参数1,参数2,参数3....);
//            objects = client.invoke("sayHello", "xiaobai");

//            String sid = "MDQyQUNDODE1N0M5MUM2QTYwMzlFNTk1ODRDNkM3MkZFMTkwOTFFOEQ1QzMzMzk0N0I1RDZGRjYxMEQxNDVGMERFNjEwQUVBNTYyMTI0NzM1OThGODdFMTBGMTZBQjAyMzIzODlENzUyN0I0NEVDODk1QkE3MzVCQ0NDMkQwNkFGRjc1QkM0ODQ3MDNFQUJFREZDRTZBMDE0RUM2RDM3ODU3NThDQTM0M0Q3NERENUFEMzkwM0VDQzhFQTVBNzBGMjhFQ0U1QzUwM0NGMzZGODVEQzczODA3MTQwQjQ3Rjk2MUFGRDlEQzRCNTMyMThFQzlGOTVDMkJBRDk5RTlFN0UzMkY0OUU0MURGMjNFQzJFNjNENTE3MkJFNjRDMkEzQTY2MzFCMUQwQUF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cxMzk3NDI3";
//            objects = client.invoke("getSM4SignInfo", sid);
//            System.out.println("返回数据:" + objects[0]);

            String xml = "U0c1VVREejFoUUtzUFl1WS9YV2Z0eG4vRmFVTy9LOElDS1NTckRGZklvV2hEQ1d0a0llN05Ba1dMY1I0ZWlGRWJpUzRTMUVidUZ3Nmk0R2UxbGxlV2dQdzhkOEN5VWJWT3JTdUt1cTNKcU01TUlIS3NMYzVmYmk5ODJuMHFaMjFVWlVRWjVGYjZKdytRSnNzb0xGZXJZUStzS2w1VDlsaVhvYmVCR3licDArMzdqNjY0dlRmenA3bEgrYUZEckdjWkZxcGFXMEJibTBpOGVDR0QrUmMvdXBoZUpJWU5telh6aDFUWUxzTW42RzU1TmtiKzNXZ2FUZ0JBSWRpT3VIMzdTYi81VThWbnRoK3kwWXNnL2ZYbHcvd3kwUWJpL3FHb2NsN1dkSEprMUxBZzhsZ09PbU1CNDBOL09RMlkvei8yaVpTeno1VmlVY2ZKUlhwTE4yTTJFSC9sZ2tKTnJDV3lla3BTRXI3K1dBY1RMMG9EM01DcmVBSTlYcEw5dnFtUWtKZEMyZlhhZGkzQlIvZlJDdTJFckVYN2I5bEJpTzJ6aWdIK0JvNStEUy8va0dwb2dZNW5YaWprZHlPV0ZJSWpRYWh4V044UlhEemNiSkZqWE9OVUxXYWxielNTRk9aM0FhTktKejhkVTR4Z3M4WDZkQVNjTkNtK0NkTkkvOThja0xxYUw5UWtjVCtkeUZIa3pEVC9qQ0lreFNIeTFmb0xKWXRnVFZFRGs4RzU0S0R5TlhCQUh0U0pFU05KRmptaURDZ1F3QnZkQlc3NWNjcXpCLzJ2WnlCYUdPbXJicHhnV003aE1ZOTlYcFRxOU5IeGJyN1gwQUZPVGtmMm9VU1Vqazg4bStFdkUyMUJldjJaeVkxMzIvRWJ1bVRjc002R3FOSVNVVnBPNmJYSWRNd1VlNVF6d3VvbzVibnVzZG9OSlErZ3hlcFVHOVNKRjZ1WXdlWHRIa1pWenhCbWZvd0c0a2hxcUxJc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YkkxdkE3czNjN3J2RzhYVVlRYVhDTmk4Nm5aZTZzOVc5c2swODdPQkdpdz0=";
            objects = client.invoke("pushPayMainInfo", xml,"7487f9ae07fb4cef9a24228012cb7221");
            System.out.println("返回数据:" + objects[0]);

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
